# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=dav1d
pkgver=1.4.1
pkgrel=0
pkgdesc="small and fast AV1 Decoder"
url="https://code.videolan.org/videolan/dav1d"
arch="all"
license="BSD-2-Clause"
makedepends="nasm meson"
subpackages="$pkgname-dev lib$pkgname:libs"
source="https://code.videolan.org/videolan/dav1d/-/archive/$pkgver/dav1d-$pkgver.tar.bz2
	fix-rv64.patch"

build() {
	case "$CARCH" in
		armhf*) meson_opts="-Denable_asm=false" ;;
		*) meson_opts="-Denable_asm=true" ;;
	esac

	CFLAGS="$CFLAGS -O2" \
	CXXFLAGS="$CXXFLAGS -O2" \
	abuild-meson \
		-Db_lto=true \
		-Denable_tests=true \
		-Denable_tools=true \
		-Dfuzzing_engine=none \
		-Dtestdata_tests=false \
		$meson_opts \
		build
	meson compile -C build
}

check() {
	meson test --no-rebuild --print-errorlogs -C build
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C build
}

sha512sums="
b2dcdeeb3d6c37788b4c697b497b9282738b758927ffbdbe72b05b1b26a61aa967dfba0ce05828b5bd5bcac93eb3394b0eafbb57e325d037867cf720d64ba099  dav1d-1.4.1.tar.bz2
1677b906a37d05d7ec692ce484b85ce2fca62f1ca4062d2dbed863748d2e453bc45fbb31a0327e6c920ccfe4b22e7204b0b12e8ee82a9e2c5c670e2c4433f22d  fix-rv64.patch
"
